package com.cloudxingkong.dianyinke.NewTeacher.Adapter;

import android.content.Context;
import android.graphics.Bitmap;
import android.util.LruCache;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.cloudxingkong.dianyinke.NewTeacher.bean.StudentState;
import com.cloudxingkong.dianyinke.R;
import com.cloudxingkong.dianyinke.TeacherApp;
import com.nostra13.universalimageloader.core.ImageLoader;

import java.util.List;

import de.hdodenhof.circleimageview.CircleImageView;

/**
 * Created by 云星空科技 on 2016/3/17.
 */
public class MTWeishangkeAdapter extends BaseAdapter {
    private List<StudentState.ListBean> data;
    private Context context;
    private String type;
    private final String TYPE_YFK="1";
    private final String TYPE_WSK="2";
    private final String TYPE_WJK="3";
    public MTWeishangkeAdapter(List<StudentState.ListBean> data, Context context,String type) {
        this.data = data;
        this.type=type;
        this.context = context;

    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder=null;
        if (convertView == null) {
            convertView=View.inflate(context, R.layout.item_weishangke,null);
            holder=new ViewHolder();
            holder.ivCover= (CircleImageView) convertView.findViewById(R.id.mt_wsk_cover);
            holder.classDate= (TextView) convertView.findViewById(R.id.mt_wsk_date);
            holder.classPay= (TextView) convertView.findViewById(R.id.mt_wsk_classpay);
            holder.classPrice= (TextView) convertView.findViewById(R.id.mt_wsk_price);
            holder.classState= (TextView) convertView.findViewById(R.id.mt_wsk_class);
            holder.classWay= (TextView) convertView.findViewById(R.id.mt_wsk_classway);
            holder.title= (TextView) convertView.findViewById(R.id.mt_wsk_title);
            holder.studentName= (TextView) convertView.findViewById(R.id.mt_wsk_studentname);
            convertView.setTag(holder);
        }else{
            holder= (ViewHolder) convertView.getTag();
        }
        holder.classWay.setText(data.get(position).getClasstype());
        holder.title.setText(data.get(position).getTitle());
        holder.classPrice.setText(data.get(position).getMoney()+"");

        holder.studentName.setText(data.get(position).getAliasname());
        if (data.get(position).getAvatar() != null && !data.get(position).getAvatar().equals("")) {
            String avatar = data.get(position).getAvatar();
            ImageLoader.getInstance().displayImage(avatar,holder.ivCover);
        }

        if (type.equals(TYPE_YFK)) {
            holder.classState.setText("已付款");
        }else if (type.equals(TYPE_WSK)) {
            holder.classState.setText("未上课");
        }else if (type.equals(TYPE_WJK)) {
            holder.classState.setText("未结款");
        }

        return convertView;
    }
    private class ViewHolder{
        CircleImageView ivCover;
        TextView title,classWay,classPrice,classDate,classState,classPay,studentName;
    }
}
